/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.upn.sigemfi.rec.be;

import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Programador
 */
@Entity
@Table(name = "REC_CREDITO_CARTERA")
@NamedQueries({@NamedQuery(name = "CreditoCartera.findAll", query = "SELECT c FROM CreditoCartera c"), @NamedQuery(name = "CreditoCartera.findByTipoCartera", query = "SELECT c FROM CreditoCartera c WHERE c.tipoCartera = :tipoCartera"), @NamedQuery(name = "CreditoCartera.findByIdCartera", query = "SELECT c FROM CreditoCartera c WHERE c.creditoCarteraPK.idCartera = :idCartera"), @NamedQuery(name = "CreditoCartera.findByIdCredito", query = "SELECT c FROM CreditoCartera c WHERE c.creditoCarteraPK.idCredito = :idCredito")})
public class CreditoCartera implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CreditoCarteraPK creditoCarteraPK;
    @Column(name = "TIPO_CARTERA", length = 10)
    private String tipoCartera;
    @OneToMany(mappedBy = "creditoCartera", fetch = FetchType.LAZY)
    private List<CompromisoPago> compromisoPagoList;
    @OneToMany(mappedBy = "creditoCartera", fetch = FetchType.LAZY)
    private List<Notificacion> notificacionList;
    @OneToMany(mappedBy = "creditoCartera", fetch = FetchType.LAZY)
    private List<CastigoCredito> castigoCreditoList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "creditoCartera", fetch = FetchType.LAZY)
    private List<AccionCobranza> accionCobranzaList;
    @JoinColumn(name = "ID_CARTERA", referencedColumnName = "ID_CARTERA", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Cartera cartera;
    @OneToMany(mappedBy = "creditoCartera", fetch = FetchType.LAZY)
    private List<Condonacion> condonacionList;
    @OneToMany(mappedBy = "creditoCartera", fetch = FetchType.LAZY)
    private List<ActaVenta> actaVentaList;
    @OneToMany(mappedBy = "creditoCartera", fetch = FetchType.LAZY)
    private List<BienAdjudicado> bienAdjudicadoList;
    @OneToMany(mappedBy = "creditoCartera", fetch = FetchType.LAZY)
    private List<ConstanciaIrrecuperabilidad> constanciaIrrecuperabilidadList;

    public CreditoCartera() {
    }

    public CreditoCartera(CreditoCarteraPK creditoCarteraPK) {
        this.creditoCarteraPK = creditoCarteraPK;
    }

    public CreditoCartera(long idCartera, long idCredito) {
        this.creditoCarteraPK = new CreditoCarteraPK(idCartera, idCredito);
    }

    public CreditoCarteraPK getCreditoCarteraPK() {
        return creditoCarteraPK;
    }

    public void setCreditoCarteraPK(CreditoCarteraPK creditoCarteraPK) {
        this.creditoCarteraPK = creditoCarteraPK;
    }

    public String getTipoCartera() {
        return tipoCartera;
    }

    public void setTipoCartera(String tipoCartera) {
        this.tipoCartera = tipoCartera;
    }

    public List<CompromisoPago> getCompromisoPagoList() {
        return compromisoPagoList;
    }

    public void setCompromisoPagoList(List<CompromisoPago> compromisoPagoList) {
        this.compromisoPagoList = compromisoPagoList;
    }

    public List<Notificacion> getNotificacionList() {
        return notificacionList;
    }

    public void setNotificacionList(List<Notificacion> notificacionList) {
        this.notificacionList = notificacionList;
    }

    public List<CastigoCredito> getCastigoCreditoList() {
        return castigoCreditoList;
    }

    public void setCastigoCreditoList(List<CastigoCredito> castigoCreditoList) {
        this.castigoCreditoList = castigoCreditoList;
    }

    public List<AccionCobranza> getAccionCobranzaList() {
        return accionCobranzaList;
    }

    public void setAccionCobranzaList(List<AccionCobranza> accionCobranzaList) {
        this.accionCobranzaList = accionCobranzaList;
    }

    public Cartera getCartera() {
        return cartera;
    }

    public void setCartera(Cartera cartera) {
        this.cartera = cartera;
    }

    public List<Condonacion> getCondonacionList() {
        return condonacionList;
    }

    public void setCondonacionList(List<Condonacion> condonacionList) {
        this.condonacionList = condonacionList;
    }

    public List<ActaVenta> getActaVentaList() {
        return actaVentaList;
    }

    public void setActaVentaList(List<ActaVenta> actaVentaList) {
        this.actaVentaList = actaVentaList;
    }

    public List<BienAdjudicado> getBienAdjudicadoList() {
        return bienAdjudicadoList;
    }

    public void setBienAdjudicadoList(List<BienAdjudicado> bienAdjudicadoList) {
        this.bienAdjudicadoList = bienAdjudicadoList;
    }

    public List<ConstanciaIrrecuperabilidad> getConstanciaIrrecuperabilidadList() {
        return constanciaIrrecuperabilidadList;
    }

    public void setConstanciaIrrecuperabilidadList(List<ConstanciaIrrecuperabilidad> constanciaIrrecuperabilidadList) {
        this.constanciaIrrecuperabilidadList = constanciaIrrecuperabilidadList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (creditoCarteraPK != null ? creditoCarteraPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CreditoCartera)) {
            return false;
        }
        CreditoCartera other = (CreditoCartera) object;
        if ((this.creditoCarteraPK == null && other.creditoCarteraPK != null) || (this.creditoCarteraPK != null && !this.creditoCarteraPK.equals(other.creditoCarteraPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.upn.sigemfi.rec.be.CreditoCartera[creditoCarteraPK=" + creditoCarteraPK + "]";
    }

}
